import { launch } from './SpringContext'
import {  cleanBeanCache, replaceClazz,addExtBeanClazz,getBean } from './SpringFactry'
import { loadResourceConfig } from './SpringResource'
import { Clazz } from './SpringType'
import { classAnnotationGenerator,fieldAnnotationGenerator,methodAnnotationGenerator,paramterAnnotationGenerator } from './SpringAnnotation'

export * from './SpringAnnotation'
export * from './SpringContext'
export * from './SpringType'
export { 
    SpringBean,
    BeanPostProcessor,
    getBeanDefineByClass,
    getBeanDefineByBean,
    SpringContainer,
    replaceClazz,
    getBean,
    cleanBeanCache } from './SpringFactry'
export { loadResourceConfig } from './SpringResource'

class SpringPanel {
    
    classAnnotationGenerator=classAnnotationGenerator;
    fieldAnnotationGenerator=fieldAnnotationGenerator;
    methodAnnotationGenerator=methodAnnotationGenerator;
    paramterAnnotationGenerator=paramterAnnotationGenerator;


    loadConfig(data:any){
        loadResourceConfig(data);
        return this;
    }

    launch(clazz:Clazz,args?:any[]){
        return launch(clazz,args)
    }

    replaceClass<T,E extends T>(clazz:new()=>T,target:new()=>E):SpringPanel{
        replaceClazz(clazz,target)
        return  this;
    }

    clear(){
        cleanBeanCache()
        return this;
    }

    bind(clazz:Clazz){
        addExtBeanClazz(clazz)
        return this;
    }

    getBean<T>(clazz:new()=>T):T{
        return getBean(clazz);
    }
}

export const spring = new SpringPanel();